﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using MonentExam1013.Api.Read.Appliaction.Commond;
using MonentExam1013.Api.Read.Dto;
using MonentExam1013.ErrorCode;

namespace MonentExam1013.Api.Read.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class QueryController : ControllerBase
    {
        /// <summary>
        /// 中介者
        /// </summary>
        IMediator mediator;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="mediator">中介者</param>
        public QueryController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 查看用户信息
        /// </summary>
        /// <param name="request">请求</param>
        /// <returns> 返回用户信息</returns>
        [HttpGet]
        public Task<ApiResult<ApiPaging<ShowUserDto>>> ShowUser([FromQuery]ShowUserCommond request)
        {
            return mediator.Send(request);  
        }
        /// <summary>
        /// 查看角色信息
        /// </summary>
        /// <param name="request">请求</param>
        /// <returns> 返回角色信息</returns>
        [HttpGet]
        public Task<ApiResult<ApiPaging<ShowRoleDto>>> ShowRole([FromQuery]ShowRoleCommond request)
        {
            return mediator.Send(request);
        }
    }
}
